package com.fys.order.message;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

@Component
@EnableBinding(StreamClient.class)
@Slf4j
public class StreamReceiver {


    /**
    * @Description: 接收消息不回应
    */
//    @StreamListener(StreamClient.INPUT)
//    public void process(Object message){
//        log.info("StreamReceiver: {}",message);
//    }

    /**
     * @Description: 接收消息并回应
     */
    @StreamListener(StreamClient.INPUT)
    @SendTo(StreamClient.INPUT2)
    public String process(Object message){
        log.info("StreamReceiver: {}",message);
        return "Received";
    }

    /**
     * @Description: 处理回应的消息
     */
    @StreamListener(StreamClient.INPUT2)
    public void process2(Object message){
        log.info("StreamReceiver2: {}",message);
    }


}
